﻿@using Carer.Crm.ViewModel
@using Carer.Data.Enum
@model IndexModel
@{
    var filterAllUnits = Model.UserUnit == null ? Model.AllUnits : Model.AllUnits.Where(it => it.Id != Model.UserUnit.Id);
}

@if (Model.Role == EnumRole.Platform_Manager)
{

    if (Model.UserUnit != null)
    {
        <button type="button" class="btn dropdown-toggle" data-toggle="dropdown">
            @Model.UserUnit.Name
            <span class="fa fa-caret-down cls-unit-id" data="@Model.UserUnit.Id"></span>
        </button>
    }
    else
    {
        <button type="button" class="btn dropdown-toggle" data-toggle="dropdown">
            未选择
            <span class="fa fa-caret-down cls-unit-id" data="0"></span>
        </button>
    }
    <ul class="dropdown-menu" role="menu" aria-labelledby="dropdownMenu1">
        @foreach (var unit in filterAllUnits)
        {
            <li role="presentation">
                <a role="menuitem" tabindex="-1" href="/Home/SwitchUnit/@unit.Id">@unit.Name</a>
            </li>
        }

    </ul>}
else
{
    if (Model.UserUnit == null)
    {
        <button type="button" class="btn dropdown-toggle" data-toggle="dropdown">
            未选择
            <span class="fa fa-caret-down cls-unit-id" data="0"></span>
        </button>
    }
    else
    {
        <button type="button" class="btn dropdown-toggle" data-toggle="dropdown">
            @Model.UserUnit.Name
            <span class="fa fa-caret-down cls-unit-id" data="@Model.UserUnit.Id"></span>
        </button>
    }
}